package com.dkhseep.bigevent.service.impl;

import com.dkhseep.bigevent.mapper.CategoryMapper;
import com.dkhseep.bigevent.mapper.UserMapper;
import com.dkhseep.bigevent.pojo.Category;
import com.dkhseep.bigevent.service.CategoryService;
import com.dkhseep.bigevent.util.ThreadLocalUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 功能:
 * 作者:Dksheep
 * 日期:2024/10/1010:22
 */
@Service
public class CategoryServiceImpl implements CategoryService {
    @Autowired
    private CategoryMapper categoryMapper;

    @Override
    public void addCategory(Category category) {
        Map<String,Object> claims = ThreadLocalUtil.get();
        Integer id = (Integer) claims.get("id");
        category.setCreateUser(id);
        categoryMapper.addCategory(category);
    }

    @Override
    public List<Category> getCategoryList() {
        Map<String,Object> claims = ThreadLocalUtil.get();
        Integer id = (Integer) claims.get("id");
        return categoryMapper.getCategoryList(id);
    }

    @Override
    public Category getCategoryDetail(int id) {
        return categoryMapper.getCategoryDetail(id);
    }

    @Override
    public void updateCategory(Category category) {
        categoryMapper.updateCategory(category);
    }

    @Override
    public void deleteCategory(int id) {
        categoryMapper.deleteCategory(id);
    }
}
